<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <title>编辑图书</title>
    <style>
        body {
            background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
            color: #e0f7fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0; padding: 40px 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
        }
        h1 {
            color: #00f7ff;
            text-shadow: 0 0 10px #00f7ff;
            margin-bottom: 24px;
            font-size: 2.5rem;
        }
        nav {
            margin-bottom: 30px;
        }
        nav a {
            color: #01c8ff;
            text-decoration: none;
            margin: 0 12px;
            font-weight: 600;
            padding: 6px 14px;
            border-radius: 6px;
            background: linear-gradient(90deg, #00f7ff, #01c8ff);
            box-shadow: 0 0 10px #00f7ff;
            transition: transform 0.2s ease, box-shadow 0.3s ease;
        }
        nav a:hover {
            transform: scale(1.05);
            box-shadow: 0 0 15px #00f7ff;
        }
        form {
            background: rgba(255, 255, 255, 0.05);
            padding: 30px 40px;
            border-radius: 14px;
            box-shadow: 0 0 20px rgba(0, 247, 255, 0.25);
            width: 100%;
            max-width: 600px;
            display: flex;
            flex-direction: column;
            gap: 18px;
        }
        label {
            font-weight: 600;
            margin-bottom: 6px;
            display: inline-block;
            color: #00e5ff;
        }
        input[type="text"],
        input[type="date"],
        select,
        textarea {
            width: 100%;
            padding: 10px 14px;
            border-radius: 8px;
            border: none;
            background: #142f43;
            color: #c9f6ff;
            font-size: 1rem;
            box-shadow: inset 0 0 8px #014a6f;
            resize: vertical;
            transition: background 0.3s ease;
        }
        input[type="text"]:focus,
        input[type="date"]:focus,
        select:focus,
        textarea:focus {
            background: #0b1f2e;
            outline: none;
            box-shadow: 0 0 10px #00f7ff;
            color: #e0f7fa;
        }
        textarea {
            min-height: 100px;
        }
        input[type="submit"] {
            background: linear-gradient(90deg, #00f7ff, #01c8ff);
            border: none;
            color: #001f29;
            font-weight: 700;
            padding: 12px 0;
            border-radius: 12px;
            cursor: pointer;
            font-size: 1.1rem;
            box-shadow: 0 0 15px #00f7ff;
            transition: background 0.3s ease, box-shadow 0.4s ease;
        }
        input[type="submit"]:hover {
            background: linear-gradient(90deg, #01c8ff, #00e5ff);
            box-shadow: 0 0 25px #00e5ff;
        }
        p {
            margin: 0;
            display: flex;
            flex-direction: column;
        }
    </style>
</head>
<body>
    <h1>编辑图书</h1>
    <nav>
        <a href="/books">图书管理</a> |
        <a href="/">首页</a>
    </nav>
   <form action="/books/edit/{{.Book.ID}}" method="post">
    <!-- 加入隐藏字段，确保后端能接收到图书 ID -->
    <input type="hidden" name="id" value="{{.Book.ID}}" />

    <p>
        <label for="title">标题:</label>
        <input id="title" type="text" name="title" value="{{.Book.Title}}" required />
    </p>
    <p>
        <label for="author">作者:</label>
        <input id="author" type="text" name="author" value="{{.Book.Author}}" required />
    </p>
    <p>
        <label for="publisher">出版社:</label>
        <input id="publisher" type="text" name="publisher" value="{{.Book.Publisher}}" />
    </p>
    <p>
        <label for="category_id">分类:</label>
        <select id="category_id" name="category_id">
            <option value="">未分类</option>
            {{range .Categories}}
            <option value="{{.ID}}" {{if eq .ID $.Book.CategoryID}}selected{{end}}>{{.Name}}</option>
            {{end}}
        </select>
    </p>
    <p>
        <label for="published_at">出版日期:</label>
        <input id="published_at" type="date" name="published_at" value="{{if .Book.PublishedAt}}{{.Book.PublishedAt.Format "2006-01-02"}}{{end}}" />
    </p>
    <p>
        <label for="description">描述:</label>
        <textarea id="description" name="description">{{.Book.Description}}</textarea>
    </p>
    <p>
        <input type="submit" value="保存" />
    </p>
</form>

</body>
</html>
